package com.birdpiss.web.domain;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;

import com.birdpiss.commons.domain.Account;

/**
 * The Class WebTransaction.
 *
 * @author mark
 */
public class WebTransaction implements Serializable {

	private static final long serialVersionUID = -5556465093885088356L;
	private String creditUserId;
	private Account debitAccount;
	private BigDecimal amount;
	private String accountType;

	/**
	 * Instantiates a new web transaction.
	 */
	public WebTransaction() {
		super();
		this.debitAccount = new Account();
	}

	/**
	 * Gets the credit user id.
	 *
	 * @return the credit user id
	 */
	public String getCreditUserId() {
		return this.creditUserId;
	}

	/**
	 * Sets the credit user id.
	 *
	 * @param creditUserId the new credit user id
	 */
	public void setCreditUserId(String creditUserId) {
		this.creditUserId = creditUserId;
	}

	/**
	 * Gets the debit account.
	 *
	 * @return the debit account
	 */
	public Account getDebitAccount() {
		return this.debitAccount;
	}

	/**
	 * Sets the debit account.
	 *
	 * @param debitAccount the new debit account
	 */
	public void setDebitAccount(Account debitAccount) {
		this.debitAccount = debitAccount;
	}

	/**
	 * Gets the amount.
	 *
	 * @return the amount
	 */
	public BigDecimal getAmount() {
		return (this.amount != null) ? this.amount.setScale(2, RoundingMode.DOWN) : null;
	}

	/**
	 * Sets the amount.
	 *
	 * @param amount the new amount
	 */
	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	/**
	 * Gets the account type.
	 *
	 * @return the account type
	 */
	public String getAccountType() {
		return this.accountType;
	}

	/**
	 * Sets the account type.
	 *
	 * @param accountType the new account type
	 */
	public void setAccountType(String accountType) {
		this.accountType = accountType;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();

		sb.append("\nCredit User Id: " + this.creditUserId);
		sb.append("\nDebit Account: " + this.debitAccount);
		sb.append("\nAmount: $" + this.amount);

		return sb.toString();
	}

}
